

package com.dog.basics.admin.controller.wishwash.api;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.dog.basics.bean.dto.api.wishwash.ApiBindingCodeDto;
import com.dog.basics.bean.dto.api.wishwash.ApiDogHxDevNodeFromDto;
import com.dog.basics.bean.dto.api.wishwash.ApiUserLoginDto;
import com.dog.basics.bean.vo.api.wishwash.ApiDogHxDevInfoVo;
import com.dog.basics.bean.vo.api.wishwash.ApiDogHxDevNodeVo;
import com.dog.basics.common.annotation.ApiLog4j;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.wishwash.DogHxDevNodeService;
import com.dog.basics.service.wishwash.DogHxDevService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;

/**
 * 设备信息
 *
 * @author cy code generator
 * @date 2021-07-09 17:40:27
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/dev")
@Api(value = "设备信息管理", tags = "API:设备信息管理")
public class ApiDogHxDevController {

    private final DogHxDevService dogHxDevService;
    private final DogHxDevNodeService dogHxDevNodeService;


    @ApiLog4j
    @Inner
    @GetMapping("/test/one")
    public R<String> getTestOne() {
        ApiDogHxDevNodeFromDto obj = new ApiDogHxDevNodeFromDto();
        obj.setDevId(1496446981002686465L);
        IPage<ApiDogHxDevNodeVo> apiPageList = dogHxDevNodeService.getApiPageList(new PageParam(), obj);
        String retur = StrUtil.format("GET: {}:{}", IdWorker.getIdStr(), JSONUtil.toJsonStr(apiPageList));
        return R.ok(retur);
    }


    @ApiLog4j
    @Inner
    @PostMapping("/test/tow")
    public R<String> putTestTow() {
        ApiDogHxDevNodeFromDto obj = new ApiDogHxDevNodeFromDto();
        obj.setDevId(1496446981002686465L);
        IPage<ApiDogHxDevNodeVo> apiPageList = dogHxDevNodeService.getApiPageList(new PageParam(), obj);
        String retur = StrUtil.format("POST: {}:{}", IdWorker.getIdStr(), JSONUtil.toJsonStr(apiPageList));
        return R.ok(retur);
    }

    /**
     * 设备登录
     *
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiLog4j
    @Inner
    @ApiOperation(value = "设备登录", notes = "设备登录【第二步】")
    @PostMapping("/login")
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    public R<ApiDogHxDevInfoVo> getById(@RequestBody ApiBindingCodeDto dto) {
        return R.ok(dogHxDevService.getById(dto));
    }

    /**
     * @功能描述: 设备绑定编码
     * @author He
     * @date 2021/7/27
     */
    @ApiLog4j
    @Inner
    @ApiOperation(value = "设备绑定", notes = "设备绑定【第一步】")
    @PutMapping("/bing/ding")
    public R<Boolean> editBindingCodeDevice(@RequestBody ApiBindingCodeDto dto) {
        return R.ok(dogHxDevService.editBindingCodeDevice(dto));
    }

    /**
     * @功能描述: 管理人员登录
     * @author He
     * @date 2021/8/6
     */
    @ApiLog4j
    @Inner
    @ApiOperation(value = "管理人员登录", notes = "管理人员登录【第三步】")
    @PostMapping("/user/login")
    public R<Boolean> getLogin(@RequestBody ApiUserLoginDto dto) {
        return R.ok(dogHxDevService.getLogin(dto));
    }


}
